package plugin

import (
	"dingbot/tools"
	"os"
	"path/filepath"

	lua "github.com/yuin/gopher-lua"
)

type PluginDataGroupMsg struct {
	Group_id string
	Message  string
}

func GroupMsgDo(msg_data PluginDataGroupMsg) {
	root_path, _ := os.Getwd()
	plugins := GetPlugins()
	for _, i := range plugins {
		if i.Enable && tools.IsFileExist(filepath.Join(root_path, "plugin_data", i.Name+".ding")) {
			RunLuaFuncWithParam(filepath.Join(root_path, "plugin_data", i.Name+".ding"), "DingbotGroupEvent", lua.LString(msg_data.Group_id), lua.LString(msg_data.Message))
		}
	}
}
